import React, { FC } from "react";
import pattern, { RegName } from "../pattern";

interface TProps {
  args: [RegName, string?];
  validateStr: string;
}

const Example: FC<TProps> = ({ args: [name, para], validateStr }) => {
  const { pattern: reg, message } = pattern(name, para);
  return (
    <div>
      <div>
        正则: <code>{reg.toString()}</code>
      </div>
      <hr />
      <div>信息回显: {message}</div>
      <hr />
      <div>待校验字符串: {validateStr}</div>
      <hr />
      <div>
        校验结果: <code>{reg.test(validateStr).toString()}</code>
      </div>
    </div>
  );
};

export default Example;
